# 创建
s = ''

s1 = 'asdfasgq'
print('s1------>',s1)

s2 = "qwewtqrfda"
print('s2------->',s2)

s3 = """
afdsgfshdgkjh
asdfajkdflkj
qweqrrrryodsf
"""
print('s3------->',s3)

s4 = str(range(5))
print('s4-------->',s4,type(s4))

# 字符串遍历
for i in s2:
    print(i)

for inx,i in enumerate(s2):
    print(inx,i)

# 成员判断
res = 'a' in s2
print(res)

res1 = 'a' not in s2
print(res1)

# 运算符操作
res3 = s1 + s2
print(res3)

s5 = 'ab'
res4 = s5*3
print('res4---->',res4)

# 格式化字符串
print('asd%safdf%s'%(11,111))

print('asda%05dfdgsd%d'%(5,12))

print('adsfads%.2f'%(3.1415926))

print('as{0}sd{1}afg{2}'.format('#','##','###'))

# 索引、切片
s6 = 'adsfagdhfkg213246987sadfsjdafslkj'
print(s6[3])

print(s6[-2])

print(s6[3:12:3])

# replace(old,new,max)
print('s6------>',s6)
print(s6.replace('a','@@@',3))

# str.split()
res5 =  s6.split('d')
print(res5)

# "".join(str)
print("$$$$".join(res5))

# str.count(s)
print('s3--------->',s3)
print(s3.count('a'))

# str.index(s) # 找不到抛异常
s7 = 'adfasdfa'
print(s7.index('a'))

# print(s7.index('g')) # ValueError: substring not found

# str.find(s) # 找不到返回-1
print(s7.find('g'))
print(s7.index('d'))

# str.upper()
res6 = s7.upper()
print('res6----->',res6)

# str.lower()
print(res6.lower())

# str.strip(s)
s8 = '!   asdfsaf  @!'
print(s8.strip())
print(s8.strip('@! '))

# str.title()
s9 = 'asd'
print(s9.title())

# str.rjust(width,[,fillchar])
print(s9.rjust(8,'0'))

# str.ljust(width,[,fillchar])
print(s9.ljust(8,'0'))

# str.islower()
print(s9.islower())

# str.isupper()
print(s9.isupper())

# str.isalpha()
print(s9.isalpha())

# str.isdigit()
print(s9.isdigit())

# str.istitle()
print(s9.istitle())

# str.isalnum()
s10 = 'ads124adfac45543adafd'
print(s10.isalnum())

# str.starswith()
print(s10.startswith('a'))


# str.endswith()
print(s10.endswith('fd'))

# 字符串的内置方法
# len()
print(len(s10))

# max() 字母转换为对应ACILL进行比较,返回最大ACLL码对应的字符
print(max(s10))

# min()
print(min(s10))

# sorted()
print(sorted(s10))